package com.xmb.common.controller.internal;

import com.xmb.common.entity.structure.UserPropertyInfo;
import com.xmb.common.params.AssetsBlotterParam;
import com.xmb.common.service.UserAssetsService;
import com.xmb.common.service.UserBalanceService;
import com.xmb.common.service.UserBonusService;
import com.xmb.common.service.UserScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by lyndon on 2019/4/11.
 */
@RestController
public class UserAssetsController {



    @Autowired
    private UserAssetsService userAssetsService;

    @Autowired
    private UserBonusService userBonusService;

    @Autowired
    private UserScoreService userScoreService;

    @Autowired
    private UserBalanceService userBalanceService;


    /**
     * 增加用户奖励流水
     * @param
     */
    @PostMapping(value = "saveAssetsBlotter")
    public int saveAssetsBlotter(@RequestBody AssetsBlotterParam assetsBlotterParam){
        return userAssetsService.saveAssetsBlotter(assetsBlotterParam);
    }

    /**
     * 增加用户奖励流水
     * @param
     */
    @PostMapping(value = "saveAssetsBlotterList")
    public void saveAssetsBlotterList(@RequestBody List<AssetsBlotterParam> assetsBlotterParamList){
        userAssetsService.saveAssetsBlotterList(assetsBlotterParamList);
    }


    @GetMapping(value = "getUserPropertyInfo/{uid}")
    public UserPropertyInfo getUserPropertyInfo(@PathVariable(value = "uid") Long uid){
        UserPropertyInfo userPropertyInfo = new UserPropertyInfo();
        userPropertyInfo.setTotalScore(userScoreService.getTotalScore(uid));
        userPropertyInfo.setTotalBalance(userBalanceService.getTotalBalance(uid));
        userPropertyInfo.setTotalBonus(userBonusService.getTotalBonus(uid));
        return userPropertyInfo;
    }


}
